<link href='<?php print ASSETS_URL?>/js/jqueryPlugins/jqgrid/css/ui.jqgrid.css' rel='stylesheet' type='text/css'>
 
<script type='text/javascript' src='<?php print ASSETS_URL?>/js/jqueryPlugins/jqgrid/js/jquery.jqGrid.min.js'></script>
<script type='text/javascript' src='<?php print ASSETS_URL?>/js/jqueryPlugins/jqgrid/js/i18n/grid.locale-ro.js'></script> 
<div class="my-account form-container">
	<div class="col-left sidebar">
		<div class="block block-account">
			<div class="block-title">
				<strong>
					<span><?=lang('my_account')?></span>
				</strong>
			</div>
			<div class="block-content">
				<ul>
					<li >
						<a href="<?=site_url('user/dashboard')?>">
						<?=lang('my_dashbord')?>
						</a>	
					</li>
					<li>
						<a href="<?=site_url('user/my_account/')?>">
							<?=lang('account_info')?>
						</a>
					</li>
					<li>
						<a href="<?=site_url('user/my_address/')?>">
							<?=lang('my_address')?>
						</a>					
					</li>
					<li >
						<a href="<?=site_url('user/address_book')?>">
						<?=lang('address_book')?>
						</a>	
					</li>
					<li class="current">
						<strong>
						<a href="<?=site_url('user/my_orders/')?>" style="border:none;">
							<?=lang('my_orders')?>
						</a>	
						</strong>					
					</li>
					<li >
						<a href="<?=site_url('user/newsLetter')?>">
						<?=lang('newsletter')?>
						</a>	
					</li>
					<li class="last">
						<a href="<?=site_url('user/logout/')?>">
							<?=lang('logout')?>
						</a>
					</li>
				</ul>
			</div>
		</div>
	</div>
	<div class="col-main" style=" width: 760px; padding-left:30px">
	<h1><?=lang('order_details')?></h1>
		<div class="block block-account">
			<div class="block-title">
				<strong>
					 <a href="JavaScript: showTrackInfo()"><?=lang('shipping_informations')?></a>&nbsp;&nbsp;&nbsp;&nbsp;
					  <a href="JavaScript: showValuationOrder('<?=$order->id?>')"><?=lang('valuation_document')?></a>&nbsp;&nbsp;&nbsp;&nbsp;
		 		<?php 	if(($order->advance_of_maney < 100 && $order->advance_of_maney != 0)|| ($order->advance_of_maney > 0 && $order->advance_of_maney != 100)){
			 				echo '<a href="JavaScript: showInvoice('.$order->id.', \'1\')">'.lang('show_invoice_rate_1').'</a>&nbsp&nbsp&nbsp&nbsp '.
			 							'<a href="JavaScript: showInvoice('.$order->id.', \'2\')">'.lang('show_invoice_rate_2').'</a> ';
						} else {
			 				echo '<a href="JavaScript: showInvoice('.$order->id.', \'0\')">'.lang('show_invoice').'</a>';
			 			}
			 			
			?>
				</strong>
			</div>
		</div>
		<div style="width:375px" class="left">
			<h2><?=lang('shipping_address')?></h2>
			<hr/>
			<?php echo $shipping->first_name .' '. $shipping->last_name .'<br/> '.$shipping_country->name .'<br/> '.  $shipping->city.'<br/> '. $shipping->state_provide.'<br/> '.$shipping->address.'<br/> '. $shipping->tel_number ;?>
			
		</div>
		<div style="width:375px" class="lpadding10 left">
			<h2><?=lang('shipping_method')?></h2>
			<hr/>
			<?=$curier->name?>
		</div>
		<div class="clear"></div>
		<div style="width:375px" class="left">
			<h2><?=lang('billing_address')?></h2>
			<hr/>
			<?php echo $billing->first_name .' '. $billing->last_name .'<br/> '.$billing_country->name  .'<br/> '.  $billing->city.'<br/> '. $billing->state_provide.'<br/> '.$billing->address.'<br/> '. $billing->tel_number ;?>
		</div>
		<div style="width:375px" class="lpadding10 left">
			<h2><?=lang('payment_method')?></h2>
			<hr/>
			<?php if ($order->order_type){ echo lang('credit_card');}else{echo lang('bank_transfer');}?>
		</div>
		<div class="clear"></div>
		<h2><?=lang('items_ordered')?></h2>
		<div style="width:100%"> 
		<div class="cartImage  left">&nbsp;</div>
		<div class="left  lpadding10 " style="width: 325px"><?=lang('product_name')?></div>
		<div class="left lpadding10 cartSubtotal"  style="width: 95px"><?=lang('unic_price')?></div>
		<div class="left lpadding10 "><?=lang('qty')?></div>
		<div class="left lpadding10 cartSubtotal" style="width: 95px"><?=lang('subtotal')?></div>
		<div class="clear"></div>
		<hr/>
		
	 </div>	
	<div class="clear"></div>
	<?php 
	$i = 0;
	$products = json_decode($order->products);
	
	foreach ($products->content as $items){ 
		$i++;
		?>
			<div class=" left">
				<div class="image-container left">
					<img src="<?php echo ASSETS_URL . 'catalog/small/' . $items->options->imageUrl;?>" />
					<a class="zoom"href="<?php echo (file_exists(LARGE_IMAGE_URL . $items->options->imageUrl) ? LARGE_IMAGE_URL . $items->options->imageUrl : NORMAL_IMAGE_URL . $items->options->imageUrl) ?>"rel="shadowbox"></a>
			    </div>
			</div>	
			<div class="left lpadding10" style="width: 325px">
				<div class="product_name"><?php echo $items->name; ?></div>
					<p>
						<strong><?=lang('cart_metal');?>:</strong> <?php echo $items->options->metal; ?><br />
						<strong><?=lang('colour');?>:</strong> <?php echo $items->options->colour; ?><br />
						<strong><?=lang('carat_weight');?>:</strong> <?php echo $items->options->carat_weight; ?><br />
						<strong><?=lang('diamond_size_text');?>:</strong> <?php echo $items->options->diamond_size_text; ?><br />
						<strong><?=lang('ring_band_width');?>:</strong> <?php echo $items->options->ring_band_width; ?><br />
						<?php if (isset($items->options->engraving_text)){?>
						<strong><?=lang('engraving_text');?>:</strong> <?php echo $items->options->engraving_text; ?><br />
						<?php  } if (isset($items->options->special_requirements)){?>
						<strong><?=lang('special_requirements');?>:</strong> <?php echo $items->options->special_requirements; ?><br />
						<?php } ?>
						<strong><?=lang('ring_size');?>:</strong> <?php echo $items->options->ring_size; ?><br />
					</p>
			</div>	
			<div class="left lpadding10" style="width: 95px">
				<?php echo $this->cart->format_number($exchange->transformPrice($items->subtotal,$sel_currency, true, false, false, 0, ($billing->natural_person)? false : true)) . ' ' . $sel_currency;?>
			</div>	
			<div class="left lpadding10">
				<?php echo form_input(array('name' => $i.'_qty', 'value' => $items->qty, 'maxlength' => '2', 'size' => '1', 'id'=>'cartInput' , 'disabled'=>'disabled')); ?>
			</div>	
			<div class="left lpadding10" style="width: 95px">
				<?php echo $this->cart->format_number($exchange->transformPrice($items->subtotal,$sel_currency, true, false, false, 0, ($billing->natural_person)? false : true)) . ' ' . $sel_currency;?>
			</div>	
			<div class="clear"></div>
			<hr/>
				<?php 
		}
		$total = $exchange->transformPrice($products->total,$sel_currency, true , $order->discount, false, 0, ($billing->natural_person)? false : true);
		echo form_hidden('countItem',$i);
		?>
			
			<div class="right">
				<ul class="cart-list">
					<li class="left-lsit">
						<strong><?=lang('total_price')?></strong>
					</li>
					<li class="right-lsit">
						<?php echo $this->cart->format_number(  $total) . ' ' . $sel_currency;?>
					</li>
				</ul>
				<ul class="cart-list">
					<li class="left-lsit">
						<strong><?=lang('tax')?></strong>
					</li>
					<li class="right-lsit">
						<?php echo $this->cart->format_number($exchange->getTax(($billing->natural_person) ? $products->total : 0 ,$sel_currency , true , $order->discount)) . ' ' . $sel_currency;?>
					</li>
				</ul>
				<ul class="cart-list">
					<li class="left-lsit">
						<strong><?=lang('discount')?></strong>
					</li>
					<li class="right-lsit">
						<?php echo  $order->discount ; ?>%
					</li>
				</ul>
				<ul class="cart-list special-cart-list">
					<li class="left-lsit">
						<?=lang('grant_total')?>
					</li>
					<li class="right-lsit">
						<?php if (!$order->advance_of_maney) {
							$advance_of_maney= 100 ;
						} else {
							$advance_of_maney = $order->advance_of_maney;
						}
						echo $this->cart->format_number(($total* ($advance_of_maney/100)))  . ' ' . $sel_currency; // * $advance_of_maney /  100?>
					</li>
				</ul>
			</div>
			<div class="clear"></div>
			<br/>
			<br/>
			<br/>
		
	</div>
	<div class="clear"></div>

</div>

<div id="valuationOrder" class="hide">
	<div id="showValuationOrder" class="hide"></div>
	<table id ="loader_content_valutation" border="0" align="center">
		  <tr>
			<td><div class="loader"></div></td>
		  </tr>
	</table>
</div>
<div id="invoiceOrder" class="hide">
	<div id="showInvoiceOrder" class="hide"></div>
	<table id ="loader_content_invoice" border="0" align="center">
		  <tr>
			<td><div class="loader"></div></td>
		  </tr>
	</table>
</div>
<div id="trackInfo" class="hide">
	<table border="0" align="center">
		  <tr>
			<td><?=lang('shipping_method')?>:</td>
			<td><?=$curier->name?></td>
		  </tr>
		  <tr>
			<td><?=lang('Shiping_web')?>:</td>
			<td><?=$curier->web_page?></td>
		  </tr>
		  <tr>
			<td><?=lang('track_number')?>:</td>
			<td><?=$order->track_code?></td>
		  </tr>
	</table>
</div>

<script type="text/javascript">
$(document).ready(function() {
	
Shadowbox.init();

});
var cancel = '[cancel]';
if (lang.cancel != undefined) {
	cancel = lang.cancel;
}
var invoice = '[invoice]';
if (lang.invoice != undefined) {
	invoice = lang.invoice;
}
var valuation_document = '[valuation_document]';
if (lang.valuation_document != undefined) {
	valuation_document = lang.valuation_document;
}
var shipping_informations = '[shipping_informations]';
if (lang.shipping_informations != undefined) {
	shipping_informations = lang.shipping_informations;
}
function showTrackInfo(){
	$( "#trackInfo" ).dialog({
		modal: true,
		resizable: true,
		title: shipping_informations,
		buttons: [
			{
				text: cancel,
				click: function() {
					$(this).dialog('close');
				}
			}	
		]
	});
}
function showValuationOrder(id){
$('#loader_content_valutation').show();
$( "#valuationOrder" ).dialog({
					modal: true,
					resizable: true,
					width: 820,
					title: valuation_document,
					buttons: [
						{
							text: cancel,
							click: function() {
								$('#showValuationOrder').html('');
								$(this).dialog('close');
							}
						}	
					]
				});
	$.ajax({
		url: settings.base_url + lang.lang_key + '/user/showValuationOrder/'+ id,
		dataType: 'html',
		type: 'POST',
		success: function(data){
			$('#showValuationOrder').html(data);
			$('#loader_content_valutation').hide();
			$('#showValuationOrder').show();
		},
		complete: function() {
		}
	});					
}
function showInvoice(id, rate){
$('#loader_content_invoice').show();
$( "#invoiceOrder" ).dialog({
					modal: true,
					resizable: true,
					width: 820,
					title: invoice,
					buttons: [
						{
							text: cancel,
							click: function() {
								$(this).dialog('close');
								$('#showInvoiceOrder').html('');
							}
						}	
					]
				});
	$.ajax({
		url: settings.base_url + lang.lang_key + '/user/showInvoice/'+ id + '/'+rate,
		dataType: 'html',
		type: 'POST',
		success: function(data){
			$('#showInvoiceOrder').html(data);
			$('#loader_content_invoice').hide();
			$('#showInvoiceOrder').show();
		},
		complete: function() {
		}
	});					
}
</script>